//
//  ViewController.m
//  LuQu
//
//  Created by xp on 2017/7/25.
//  Copyright © 2017年 mingthink. All rights reserved.
//

#import "ViewController.h"
#import "TabBarController.h"
@interface ViewController (){
    UIImageView *imgv_start;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showView];
    //[self requestCheckUpdate];
    [self performSelector:@selector(gotoMainView) withObject:nil afterDelay:0.5];
}
-(void)showView{
    imgv_start = UIImageView.new;
    [self.view addSubview:imgv_start];
    imgv_start.contentMode = UIViewContentModeScaleAspectFit;
    imgv_start.sd_layout.topSpaceToView(self.view, 0).leftSpaceToView(self.view,0).rightSpaceToView(self.view, 0).bottomSpaceToView(self.view, 0);
}
- (void) gotoMainView {
    
    AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    //    SBMember *member=appDel.loginMember;
    //    if (member.AccessToken) {
    //        if (member.IsVisitor) {
    [appDel goTabMain];
    //        }else{
    //            if ([StringUtils isNotEmpty:member.Mobile]){
    //                [appDel goTabMain];
    //            }else{
    //                [appDel goLogin];
    //                [WToast showWithText:@"您还未绑定手机号，请重新用微信登录后进行绑定！" duration:3];
    //            }
    //        }
    //
    //    } else {
    //        [appDel goLogin];
    //    }
    //    //启动app刷新token
    //    NSMutableDictionary *dic_params = NSMutableDictionary.new;
    //    dic_params[@"RefreshToken"] = appDel.loginMember.RefreshToken;
    //    [HttpManager requestWithProgressTitle:nil method:HTTPS_POST path:URL_REFRESHACCESSTOKEN paramDict:dic_params finishBlock:^(id result, AFHTTPRequestOperationManager *manager) {
    //        DeLog(@"%@",result);
    //        if ([[NSString stringWithFormat:@"%@",[result objectForKey:@"Message"]] length] > 0) {
    //            [WToast showWithText:[result objectForKey:@"Message"]];
    //        }
    //        appDel.loginMember.AccessToken = [NSString stringWithFormat:@"%@",[[result objectForKey:@"Data"] objectForKey:@"AccessToken"]];
    //        appDel.loginMember.RefreshToken = [NSString stringWithFormat:@"%@",[[result objectForKey:@"Data"] objectForKey:@"RefreshToken"]];
    //        appDel.loginMember.UserId = [NSString stringWithFormat:@"%@",[[result objectForKey:@"Data"] objectForKey:@"UserId"]];
    //
    //        MemberService *service = [[MemberService alloc] init];
    //        [service insert:appDel.loginMember];
    //    }];
}
#pragma mark- 网络请求
//-(void)requestCheckUpdate{
//    NSMutableDictionary *paramsDict = [[NSMutableDictionary alloc]init];
//    paramsDict[@"map"] =@"app_version_new";
//    [HttpManager requestWithProgressTitle:nil method:HTTPS_GET path:API_PATH paramDict:paramsDict finishBlock:^(id result, AFHTTPRequestOperationManager *manager) {
//        //        AppDelegate *appDel=(AppDelegate*)[UIApplication sharedApplication].delegate;
//        //        appDel.serverVersion=[result[@"Data"][@"VersionCode"] intValue];//苹果审核用
//
//        NSInteger code = [result[@"code"] integerValue];
//        if (code==200) {
//            if ([StringUtils isNotEmpty:result[@"data"]]){
//                NSDictionary *dict=result[@"data"];
//                int serverVersion=[dict[@"ioscode"] intValue];
//                int appVersion=[[MyUtility getAppBuildVersion] intValue];
//                if (serverVersion>appVersion) {
//                    NSURL *url=[NSURL URLWithString:@"https://itunes.apple.com/cn/app/id1275980673?mt=8"];
//                    BOOL isForceUpdate=[dict[@"mode"] boolValue];
//                    NSString *updateContent=dict[@"iosdetail"];
//                    if (isForceUpdate) {
//                        [EMAlertView showAlertWithTitle:@"有新版本啦~" message:updateContent completionBlock:^(NSUInteger buttonIndex, EMAlertView *alertView) {
//                            if (buttonIndex==0) {
//                                if ([[UIApplication sharedApplication] canOpenURL:url]) {
//                                    [[UIApplication sharedApplication] openURL:url];
//                                }
//                            }
//                        } cancelButtonTitle:nil otherButtonTitles:@"立即更新",nil];
//                    }else
//                    {
//                        [EMAlertView showAlertWithTitle:@"有新版本啦~" message:updateContent completionBlock:^(NSUInteger buttonIndex, EMAlertView *alertView) {
//                            if (buttonIndex==1) {
//                                if ([[UIApplication sharedApplication] canOpenURL:url]) {
//                                    [[UIApplication sharedApplication] openURL:url];
//                                }
//                            }
//                        } cancelButtonTitle:@"取消" otherButtonTitles:@"立即更新",nil];
//                    }
//
//                }
//            }
//        }else{
//            [self.view makeToast:result[@"msg"]];
//        }
//        //            updateView=[[CustomIOSAlertView alloc]init];
//        //            updateView.containerView=[self createUpdateViewWithDataDictionary:dict];
//        //            updateView.buttonTitles=nil;
//        //            [updateView show];
//    }];
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
